<?php
	####################################################
	# library import and object instance.              #
	####################################################
	include_once('common.php');


	####################################################
	# request data($_POST AND $_GET FROM $_REQUEST)    #
	####################################################
	# REQUEST(get and post variables)

	# GET(url variables)

	# POST(form variables)

	# Validation(special case validate)

	####################################################
	# implementation                                   #
	####################################################
?>
<?php
	$html->custom_header("template");
	$html->custom_js("{$JS}jquery.1.7.1.min.js");
	$html->custom_js("{$JS}lib.control.js");
	$html->custom_css("{$CSS}basic.ntdd.css");
	$html->custom_body();
?>
<?=$tmp->tiles_header()?>
	<?php



/*
echo sqlite_libversion();
echo "<br>";
echo phpversion();
*/
//phpinfo();






	?><?php


// 1.  DB 연결
//$db = new SQLite3('/sqlite/testdb');
//
//// 2. Query 실행
//$results = $db->query('SELECT bar, shape FROM foo');
//
//// 3. Query 결과 처리
//while ($row = $results->fetchArray()) {
//              echo "$row[0]"."-"."$row[1]" ;   // $row[0]는 bar, $[row1]는 shape
//       }
//
//// 4. DB 종료
//$db->close();
?>
<?
	// SQLite 데이터베이스 열기
	// 만약 파일이 없다면 새로 생성하게 됩니다.
	$db = sqlite_open('sqlite/sqlitedb.db', 0666, $sqliteerror);

//	// 테이블 생성 SQL
//	$add_table_sql =  "CREATE TABLE sqlite_sample ( ";
//	$add_table_sql .= "uid int(11), ";
//	$add_table_sql .= "name varchar(8), ";
//	$add_table_sql .= "age varchar(3), ";
//	$add_table_sql .= "PRIMARY KEY (uid) ";
//	$add_table_sql .= "); ";

//	sqlite_query($db, $add_table_sql);
	// 자료 추가
	//sqlite_query($db, " INSERT INTO sqlite_sample VALUES ('1', '홍길동', '73') ");
	//sqlite_query($db, " INSERT INTO sqlite_sample VALUES ('2', '거시기', '22') ");
	//sqlite_query($db, " INSERT INTO sqlite_sample VALUES ('3', '아무게', '40') ");
	//sqlite_query($db, "INSERT INTO sqlite_sample VALUES((SELECT max(uid) FROM sqlite_sample)+1,'김영아', '24');");

	// 자료 뽑아 오기
//	if($result) {
//		while($info = sqlite_fetch_array($result)) {
//			Nlog::xmp($info);
//		}
//	}
	sqlite_query($db, "UPDATE sqlite_sample SET name='으악' WHERE uid='1'");
	$query = sqlite_query($db, " SELECT * FROM sqlite_sample ORDER BY uid ASC ");
	$result = sqlite_fetch_all($query, SQLITE_ASSOC);
	foreach ($result as $key=>$entry) {
		echo 'uid: ' . $entry['uid'] . '  name: ' . $entry['name'] . '  age' . $entry['age'].'<br />';
	}


	// SQLite 데이터베이스 닫기
	sqlite_close($db);
?>


<?=$tmp->tiles_footer()?>
<?php $html->html_footer(); ?>